package org.zcl.controller;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import org.zcl.api.ApiResponse;
import org.zcl.entity.RankRequest;
import org.zcl.entity.RankResponse;
import org.zcl.service.RankService;

import java.util.List;

/**
 * .
 *
 * @author zhuchenglin
 * @since 2024/4/22 16:09
 */
@RestController
@RequestMapping("/rank/")
public class RankController {

    @Autowired
    private RankService rankService;

    @PostMapping("add")
    public ApiResponse<RankResponse> add(@RequestBody RankRequest request) {
        RankResponse rankResponse = rankService.add(request);
        return new ApiResponse<RankResponse>().returnSuccess(rankResponse);
    }

    @GetMapping("rankList")
    public ApiResponse<List<RankResponse>> rankList() {
        List<RankResponse> rankResponses = rankService.rankList();
        return new ApiResponse<List<RankResponse>>().returnSuccess(rankResponses);
    }
}
